$(document).ready(function (){
    $("[name='deletecomment']").click(function (){
    var comment={};
    comment.commentid=$(this).parents("#parent").find("#commentId").attr("commentId");
    $.ajax({
        type:"POST",
        url:"/shop/deletecomment",
        contentType:"application/x-www-form-urlencoded; charset=utf-8",
        data:comment,
        dataType:"json",
        success:function (result){
            swal(result.msg);
            $("button").click(function (){
                location.reload();
            });
        },
        error:function (){
            alert("删除失败");
        }
    });
})

    var goodsId={};

    $("[name='evaluate']").click(function (){
        $("#evaluate").modal({
            backdrop:'static'
        });
        goodsId=$(this).parents("#parent").find("#goodsId").attr("goods-Id");
    })

    $("#star").raty({path: '../image/img'});

    $("#saveEvaluate").click(function (){
    var score=$("[name='score']").val();
    var content=$("#description").val();
    var comment={};
    comment.commentid=$("#parent").attr("comment-Id");
    comment.userid={};
    comment.goodsid=goodsId;
    comment.point=score;
    comment.content=content;
    $.ajax({
        type:"POST",
        url:"/shop/updatecomment",
        contentType:"application/x-www-form-urlencoded; charset=utf-8",
        data:comment,
        dataType:"json",
        success:function (result){
            $("#evaluate").modal('hide');
            location.reload();
            swal(result.msg);
        },
        error:function (){
            alert("评论失败1");
        }
        });

    })


});
